#include <stdio.h>

#include "cmsis_os2.h"
#include "ohos_init.h"

#include "iot_gpio.h"
#include "hi_io.h"
#include "hi_adc.h"

#define WATERLEVEL   HI_ADC_CHANNEL_2

int getwaterlevel()
{
    unsigned short data=0;
    IoTGpioInit(HI_IO_NAME_GPIO_5);
    hi_io_set_func(HI_IO_NAME_GPIO_5,HI_IO_FUNC_GPIO_5_GPIO);

    if(hi_adc_read(WATERLEVEL,&data,HI_ADC_EQU_MODEL_4,HI_ADC_CUR_BAIS_DEFAULT,0)==HI_ERR_SUCCESS);
    {
        printf("waterlevel=%d\n",data);
        return data;
    }

    return 0;

}

